package com.yunhe.authority.service.company;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.yunhe.authority.domain.company.Company;
import com.yunhe.authority.domain.company.ContractAccessories;
import com.yunhe.authority.model.CompanyUpload;
import com.yunhe.authority.model.OfficeManageCompanyInfoVO;
import com.yunhe.authority.model.poi.CompanyPoi;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ModelNotFoundException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.PageParam;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 企业Service
 * @author liuronglei
 */
public interface CompanyService {

    /**
     * 根据电站ID获得所有企业列表
     * @param stationId 电站ID
     */
    List<Company> findByStationId(Long stationId);

    /**
     * 根据单位ID获得所有企业列表
     * @param firmId 单位ID
     */
    List<Company> findByFirmId(Long firmId);

    /**
     * 根据ID获得企业
     * @param id 企业ID
     */
    Company findById(Long id) throws ObjectNotFoundException;

    /**
     * 根据条件获得所有企业列表
     * @param firmId 单位ID
     * @param stationId 电站ID
     */
    List<Company> getCompanys(Long firmId, Long stationId);

    /**
     * 新增企业
     * @param company 企业对象
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    Company createCompany(Company company, Long stationCode)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException, PinyinException, ModelNotFoundException;

    /**
     * 成功项目录入在园项目
     *
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    String intentionToCompany(Long intentionId, String officeIds, String title, String leaseTime, String leaseDueTime, List<ContractAccessories> contractAccessoriesList)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException, PinyinException, ModelNotFoundException;

    /**
     * 根据企业id删除企业
     * @param ids
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void deleteCompany(String ids) throws ObjectNotFoundException, ModelNotFoundException, ArgumentErrorException, UniqueConstraintsException;


    /**
     * 更新企业（全部字段）
     * @param company 企业对象
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    Company updateCompany(Company company)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException;



    Company findByCode(Long code);

    /**
     * 根据统一社会信用代码获得企业
     * @param unifiedSocialCreditCode 统一社会信用代码
     */
    Company findByUnifiedSocialCreditCode(String unifiedSocialCreditCode);

    /**
     * 根据excel模板批量导入
     * @param companyUploadList
     * @return int
     * @create 2021/2/25 10:38
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void   upload(List<CompanyUpload> companyUploadList) throws ObjectNotFoundException, UniqueConstraintsException, ArgumentErrorException, PinyinException, ModelNotFoundException;

    Page<CompanyUpload> findAllForPage(PageParam pageParam);

    Page<Company> findStationAllCompanyForPage(String searchKey, Long stationId, PageParam pageParam);

    /**
     * 导出数据
     * @param ids 导出的企业id
     * @param exportPeopleId 导出人的id
     * @return void
     * @create 2021/2/26 15:56
     */
    void export(String ids , Long exportPeopleId , HttpServletResponse httpServletResponse) throws UniqueConstraintsException;

    Iterable<Company> findByRealStationId(Long realStationId);

    Iterable<Company> findByRealStationId(Long id, String type);

    /**
     * 企业基础信息导入模板下载
     * @param exportPeopleId
     * @param httpServletResponse
     */
    void downCompanyUploadTemplate(Long exportPeopleId, HttpServletResponse httpServletResponse) throws IOException;

    /**
     * 导入
     * @param list
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void importCompanyExcel(List<CompanyPoi> list) throws ObjectNotFoundException, PinyinException, ModelNotFoundException, ArgumentErrorException, UniqueConstraintsException;

    /**
     * 导出数据
     * @param ids 导出的企业id
     */
    void exportNew(String ids, HttpServletResponse httpServletResponse) throws ObjectNotFoundException;

    /**
     * 企业离场
     * @param companyId 企业id
     * @exception ObjectNotFoundException
     * @exception ArgumentErrorException
     */
    void companyLeave(Long companyId) throws ObjectNotFoundException, ArgumentErrorException, ModelNotFoundException, UniqueConstraintsException;

    List<Company> findAll();

    /**
     * 根据员工ID查询公司
     * @param employeeId
     * @return
     */
    Company findByEmployeeId(Long employeeId);

    List<Company> findCompanyByRealStationId(Long stationId);

    /**
     * @Description 房源管理查看企业信息
     * @Param Long officeId
     * @Return OfficeManageCompanyInfoVO
     * @Date 2021/10/20 11:30
     */
    OfficeManageCompanyInfoVO getCompanyInfoByOfficeId(Long officeId);
}
